{% extends 'base.html.twig' %}
{% import 'Import/app_import.html.twig' as appImport %}

{% block head_title %}{{ 'slm_short'|trans }} - {{ policy.name }} - {{ 'history'|trans }}{% endblock %}

{% block heading_1 %}
    {{ appImport.heading({'level': 1, 'title': 'slm'|trans, 'link': {'url': path('slm')}}) }}
{% endblock %}

{% block heading_2 %}
    {{ appImport.heading({'level': 2, 'title': policy.name}) }}
{% endblock %}

{% block tabs %}
    {% include 'Modules/slm/slm_read_tabs.html.twig' with {'active': 'history'} %}
{% endblock %}

{% block main_content %}
    {% if policy.lastSuccess %}
        {% embed 'Embed/block_embed.html.twig' %}
            {% import 'Import/app_import.html.twig' as appImport %}
            {% block content %}
                {{ appImport.heading({'level': 3, 'title': 'last_success'|trans}) }}

                <p>
                    <strong>{{ 'snapshot'|trans }}</strong><br>
                    {% if is_granted('SNAPSHOTS_LIST', 'snapshot') %}
                        <a class="{{ theme_link_secondary }}" href="{{ path('snapshots_read', {'repository': policy.repository, 'snapshot': policy.lastSuccess['snapshot_name']}) }}">{{ policy.lastSuccess['snapshot_name'] }}</a>
                    {% else %}
                        {{ policy.lastSuccess['snapshot_name'] }}
                    {% endif %}
                </p>

                <p>
                    <strong>{{ 'date'|trans }}</strong><br>
                    {{ policy.lastSuccess['time']|human_datetime }}
                </p>
            {% endblock %}
        {% endembed %}
    {% endif %}

    {% if policy.lastFailure %}
        {% embed 'Embed/block_embed.html.twig' %}
            {% import 'Import/app_import.html.twig' as appImport %}
            {% block content %}
                {{ appImport.heading({'level': 3, 'title': 'last_failure'|trans}) }}

                <p>
                    <strong>{{ 'snapshot'|trans }}</strong><br>
                    {% if is_granted('SNAPSHOTS_LIST', 'snapshot') %}
                        <a class="{{ theme_link_secondary }}" href="{{ path('snapshots_read', {'repository': policy.repository, 'snapshot': policy.lastFailure['snapshot_name']}) }}">{{ policy.lastFailure['snapshot_name'] }}</a>
                    {% else %}
                        {{ policy.lastFailure['snapshot_name'] }}
                    {% endif %}
                </p>

                <p>
                    <strong>{{ 'date'|trans }}</strong><br>
                    {{ policy.lastFailure['time']|human_datetime }}
                </p>
            {% endblock %}
        {% endembed %}
    {% endif %}
{% endblock %}
